﻿using System.Collections.Generic;
using System.Text.RegularExpressions;

public enum ExplorerItemType
{
    Class, Method, Property, Event
}

public class ExplorerItem
{
    public ExplorerItemType type;
    public string funcName;
    public CLType funcType;
    public List<FunctionArgument> args = new List<FunctionArgument>();
    public int line;
}

public class FunctionArgument
{
    public CLType type;
    public string name;
}

public class CLType
{
    public string YnoteSettingsBaseType { get; private set; }
    public int Dim { get; private set; }
    public bool IsPointer { get; private set; }

    public static CLType Parse(string s)
    {
        var m = Regex.Match(s.Trim(), @"^(?<type>[a-z]+)(?<dim>\d*)(?<isPointer>\*?)$");
        if (!m.Success)
            return null;
        var result = new CLType();
        result.IsPointer = m.Groups["isPointer"].Value != "";
        result.Dim = 1;
        if (m.Groups["dim"].Value != "")
            result.Dim = int.Parse(m.Groups["dim"].Value);
        result.YnoteSettingsBaseType = m.Groups["type"].Value;

        return result;
    }

    public override string ToString()
    {
        return YnoteSettingsBaseType + (Dim > 1 ? Dim.ToString() : "") + (IsPointer ? "*" : "");
    }
}

class ExplorerItemComparer : IComparer<ExplorerItem>
{
    public int Compare(ExplorerItem x, ExplorerItem y)
    {
        return x.funcName.CompareTo(y.funcName);
    }
}
public class Tag
{
    public string Name;
    public int id;
    public int startLine;
    public string Marker { get { return Name + id; } }
}